<!--  -->
<template>
  <div class="line-echart">
    <base-echart :options="options"></base-echart>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import BaseEchart from '../../../base-ui/echarts/index'
export default defineComponent({
  components: {
    BaseEchart
  },
  props: {
    title: {
      type: Array,
      default: () => []
    },
    categoryGoodsSale: {
      type: Object,
      default: () => ({})
    }
  },
  setup(props) {
    const options = computed(() => {
      return {
        title: {
          text: props.title
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        legend: {},
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            boundaryGap: false,
            data: props.categoryGoodsSale.xLabels
          }
        ],
        yAxis: [
          {
            type: 'value'
          }
        ],
        series: [
          {
            name: '分别销量',
            type: 'line',
            stack: '总量',
            itemStyle: {
              color: '#c2e3a3'
            },
            areaStyle: {
              color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [
                  {
                    offset: 0,
                    color: '#9fe080' // 0% 处的颜色
                  },
                  {
                    offset: 1,
                    color: '#fc8452' // 100% 处的颜色
                  }
                ],
                global: false // 缺省为 false
              }
            },
            emphasis: {
              focus: 'series'
            },
            data: props.categoryGoodsSale.values
          }
        ]
      }
    })
    return { options }
  }
})
</script>
<style lang="less" scoped></style>
